package berlin.volders.badger.example;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import static org.junit.Assert.assertEquals;

public class ExampleOhosTest {
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("berlin.volders.badger.example", actualBundleName);
    }

    @Test
    public void testCircle(){
        try {
            Class badgeShape = Class.forName("berlin.volders.badger.BadgeShape");
            Method circle = badgeShape.getMethod("circle", float.class, int.class);
            Object object = badgeShape.getConstructor().newInstance();
            circle.invoke(object,1.0F, 1);
        } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testOval(){
        try {
            Class badgeShape = Class.forName("berlin.volders.badger.BadgeShape");

            Method oval = badgeShape.getMethod("oval", float.class, float.class, int.class);
            Object object = badgeShape.getConstructor().newInstance();
            oval.invoke(object,1.0F,1.0F, 1);
        } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testSquare(){
        try {
            Class badgeShape = Class.forName("berlin.volders.badger.BadgeShape");

            Method square = badgeShape.getMethod("square", float.class, int.class, float.class);
            Object object = badgeShape.getConstructor().newInstance();
            square.invoke(object,1.0F,1,1.0F);
        } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}